# Sentinel - IRC Statistical and Operator Services
# Makefile.in - Core makefile
#
# Copyright W. Campbell and others.  See README for more details
# Some code Copyright: Jonathan George, Kai Seidler, ircd-hybrid Team,
#                      IRCnet IRCD developers.
#
# $Id: Makefile.in,v 1.26 2004/01/13 14:11:35 wcampbel Exp $

CC=@CC@
RM=@RM@
MV=@MV@
CP=@CP@
AWK=@AWK@
INSTALL=@INSTALL@
PREFIX=@prefix@
CFLAGS=@CFLAGS@ @ASSERT@ -Wall -I../include -I../src/libsentinel -DPREFIX=\"${PREFIX}\"
LDFLAGS=@LDFLAGS@
LIBS=@LIBS@
BIN=sentinel@EXEEXT@
MKPASSWD=mkpasswd@EXEEXT@
TEMPLATE=@TEMPLATE@

# Debuggers need special flags - Note that a debugger will know
# how to modify these to get what he/she needs
#CFLAGS += -ggdb -pedantic -Wshadow -Wmissing-declarations

## STOP STOP STOP
## No need to change anything below
## STOP STOP STOP

MAKE = make 'CC=${CC}' 'CFLAGS=${CFLAGS}' 'LDFLAGS=${LDFLAGS}' \
            'BIN=${BIN}' 'MKPASSWD=${MKPASSWD}' 'TEMPLATE=${TEMPLATE}' \
            'RM=${RM}' 'AWK=${AWK}' 'MV=${MV}' 'LIBS=${LIBS}' \
            'PREFIX=${PREFIX}'

SUBDIRS=src tools

LIBDIR=src/libsentinel

.c.o:
	$(CC) $(CFLAGS) -c $<

all: build

clean:
	@for i in $(SUBDIRS); do \
		echo "Cleaning $$i";\
		cd $$i;\
		${MAKE} clean; cd ..;\
	done

build: 
	@for i in $(SUBDIRS); do \
		echo "Building $$i";\
		cd $$i;\
		${MAKE} build MFLAGS=""; cd ..;\
	done

cleandir: distclean

distclean: clean
	@for i in $(LIBDIR); do \
		echo "Distcleaning $$i"; \
		cd $$i; \
		make distclean; \
		cd ../..; \
	done
	$(RM) -f config.log config.cache config.status include/setup.h
	$(RM) -f bin/sentinel@EXEEXT@ bin/mkpasswd@EXEEXT@ bin/converttld@EXEEXT@
	$(RM) -f src/info.c.list
	$(RM) -f Makefile

lint:	
	@for i in $(SUBDIRS); do \
		echo "Linting $$i";\
		cd $$i;\
		${MAKE} lint; cd ..;\
	done

lclint:
	@for i in $(SUBDIRS); do \
		echo "Linting $$i";\
		cd $$i;\
		${MAKE} lclint; cd ..;\
	done

depend:
	@for i in $(SUBDIRS); do \
		echo "Making dependencies $$i";\
		cd $$i;\
		${MAKE} depend; cd ..;\
	done

converttld:
	$(CC) -o bin/converttld@EXEEXT@ tools/converttld.c

install: build
	$(INSTALL) -m 755 -d $(PREFIX)
	$(INSTALL) -m 755 -d $(PREFIX)/bin
	$(INSTALL) -m 750 -d $(PREFIX)/data
	$(INSTALL) -m 750 -d $(PREFIX)/etc
	$(INSTALL) -m 755 -d $(PREFIX)/logs
	$(INSTALL) -m 755 -c bin/$(BIN) $(PREFIX)/bin
	$(INSTALL) -m 755 -c bin/$(MKPASSWD) $(PREFIX)/bin
	$(INSTALL) -m 644 -c data/tlds.nfo $(PREFIX)/data
	$(INSTALL) -m 640 -c etc/sentinel.cfg.dist $(PREFIX)/etc
	@if [ -e $(PREFIX)/help ] ; then \
		echo Moving existing help files... ; \
		if [ -e $(PREFIX)/help.old ] ; then \
			$(RM) -rf $(PREFIX)/help.old ; \
		fi ; \
		$(MV) $(PREFIX)/help  $(PREFIX)/help.old ; \
	fi
	@echo Installing help files...
	@$(CP) -R help $(PREFIX)

